package com.gliese.bambook.handler;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware;
import org.springframework.beans.factory.xml.XmlBeanFactory;
import org.springframework.core.io.ClassPathResource;

import com.gliese.bambook.object.Snbc;
import com.gliese.bambook.service.news.interfaces.NewsAnalysisService;

public class NewsAnalyzeHandler implements BeanFactoryAware {
	private NewsAnalysisService newsAnalysisService;
	// get news Analysis service by serviceType from spring factory.
	private BeanFactory beanFactory;

	/**
	 * 
	 * @param ServiceType
	 *            such as sinaNewsAnalysisService of sina news .
	 * @param url
	 * @return
	 */
	public Snbc analyzeHandle(String ServiceType, String url) {
		// get news Analysis service by serviceType from spring factory.
		// get news Analysis service by serviceType from spring factory.

		newsAnalysisService = (NewsAnalysisService) beanFactory
				.getBean(ServiceType);
		return newsAnalysisService.analyzeNews(url);
	}

	@Override
	public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
		this.beanFactory = beanFactory;
	}
}
